﻿/**
 * 
 * @file ControlPanel.h
 * @brief 控制面板类声明
 * @author LiBaojun (libaojunqd@foxmail.com)
 * @date 2024-10-12
 * 
 */
#ifndef _CONTROLPANEL_AND_PAGE_H___
#define _CONTROLPANEL_AND_PAGE_H___
 
#include "GUIWidgetAPI.h"
#include "FITK_Kernel/FITKCore/FITKAbstractGUI.h"
#include "FITK_Component/FITKWidget/FITKTreeWidget.h"
#include <QHash>

namespace Ui
{
    class ControlPanel;
}

namespace GUI
{
    /**
     * @brief 树形菜单页类型
     * @author LiBaojun (libaojunqd@foxmail.com)
     * @date 2024-10-12
     */
    enum TreeWidgetType
    {
        PageNone,     ///< 无类型
        PageModel,
        PageProp,
        PageGroup,    ///< 分组页
        PageLoad,
    };

     /**
      * @brief 控制面板里面的树形菜单，抽象类
      * @author LiBaojun (libaojunqd@foxmail.com)
      * @date 2024-10-12
      */
    class GUIWIDGETAPI TreeWidgetPage : public Comp::FITKTreeWidget
    {
    public:
        /**
         * @brief Construct a new Tree Widget Page object
         * @param[i]  parent         父对象
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        explicit TreeWidgetPage(QWidget* parent = nullptr);
        /**
         * @brief Destroy the Tree Widget Page object
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        virtual ~TreeWidgetPage() = 0;
        /**
         * @brief 获取页类型
         * @return TreeWidgetType 
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        virtual TreeWidgetType getTreeWidgetType() = 0;
    };

    /**
     * @brief 控制面板类声明
     * @author LiBaojun (libaojunqd@foxmail.com)
     * @date 2024-10-12
     */
    class GUIWIDGETAPI ControlPanel : public Core::FITKWidget
    {
    public:
        /**
         * @brief 控制面板对象
         * @param[i]  parent         父对象
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        explicit ControlPanel(QWidget *parent = nullptr);
        /**
         * @brief Destroy the Control Panel object
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        virtual ~ControlPanel();
        /**
         * @brief 根据类型获取页面
         * @param[i]  t              类型
         * @return TreeWidgetPage* 
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        TreeWidgetPage* getTreeWidget(TreeWidgetType t);

        template <class T>
        /**
         * @brief 根据类型获取页面，并强制类型转换
         * @param[i]  t              类型
         * @return T* 
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        T* getTreeWidgetT(TreeWidgetType t)
        {
            return dynamic_cast<T*>(this->getTreeWidget(t));
        }

    
    private:
        /**
         * @brief UI对象
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        Ui::ControlPanel* _ui{};
        /**
         * @brief 树形菜单页
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-10-12
         */
        QHash<TreeWidgetType, TreeWidgetPage*> _pages{};
    };
}


#endif
